package com.crm.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 封装分页查询结果  rows
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResultTow {
    private Integer code;
    private String msg;
    private String params;
    private long total; //总记录数
    private List rows; //当前页数据集合
    public static PageResultTow success(String params, List rows, long total) {
        PageResultTow pageResult = new PageResultTow();
        pageResult.setCode(200);
        pageResult.setMsg("操作成功");
        pageResult.setParams(params);
        pageResult.setRows(rows);
        pageResult.setTotal(total);
        return pageResult;
    }
    public static PageResultTow fail(int code, String msg) {
        PageResultTow pageResult = new PageResultTow();
        pageResult.setCode(code);
        pageResult.setMsg(msg);
        return pageResult;
    }

    public static PageResultTow success(String params, List rows) {
        PageResultTow pageResult = new PageResultTow();
        pageResult.setCode(200);
        pageResult.setMsg("操作成功");
        pageResult.setParams(params);
        pageResult.setRows(rows);
        return pageResult;
    }

    public static PageResultTow success(List rows,long total) {
        PageResultTow pageResult = new PageResultTow();
        pageResult.setCode(200);
        pageResult.setMsg("操作成功");
        pageResult.setRows(rows);
        pageResult.setTotal(total);
        return pageResult;
    }
}
